<template>
	<u-tabbar :value="index" @change="tabbarChange" :fixed="true" :placeholder="true" activeColor="#d81e06"
		:safeAreaInsetBottom="true">
		<u-tabbar-item v-for="(item, index) in list" :key="index" :text="item.text" icon="photo"></u-tabbar-item>
	</u-tabbar>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						text: '首页',
						pagePath: '/pages/index/index'
					},
					{
						text: '专题',
						pagePath: '/pages/topic/topic'
					},
					{
						text: '分类',
						pagePath: '/pages/category/category'
					},
					{
						text: '购物车',
						pagePath: '/pages/cart/cart'
					},
					{
						text: '我的',
						pagePath: '/pages/user/user'
					}
				]
			};
		},
		computed: {
			index() {
				return this.$store.state.tabbarIndex;
			}
		},
		methods: {
			tabbarChange(index) {
				uni.switchTab({
					url: this.list[index].pagePath
				});
			}
		}
	};
</script>
